package com.example.userclient.activity

import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.databinding.DataBindingUtil
import com.example.userclient.Main.ClientInfoHolder
import com.example.userclient.R
import com.example.userclient.databinding.ActivityFillPhoneBinding

class FillPhoneActivity : AppCompatActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val binding = DataBindingUtil.setContentView<ActivityFillPhoneBinding>(this, R.layout.activity_fill_phone)
        binding.fillPhoneButton.setOnClickListener{
           val sharedPref: SharedPreferences = getSharedPreferences("MyApplication", Context.MODE_PRIVATE)
           with (sharedPref.edit()) {
               putString("phone",binding.fillPhoneEdit.text.toString().trim())
               apply()
           }
           ClientInfoHolder.phone = binding.fillPhoneEdit.text.toString().trim()
           Log.i("FillPhoneActivity", ClientInfoHolder.phone!!)
//           MainActivity.back(this)
           finish()
       }



    }

    companion object{
        fun actionStartFromOutSide(context: Context){
            val intent = Intent(context, FillPhoneActivity::class.java)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent)

        }


    }
}